Skip to content

feat(Feature Lifecycle): Update API with feature lifecycle info#7789

Open
emyller wants to merge 24 commits into
mainfrom
feat/feature-lifecycle-api-endpoints
Open

feat(Feature Lifecycle): Update API with feature lifecycle info#7789
emyller wants to merge 24 commits into
mainfrom
feat/feature-lifecycle-api-endpoints

Conversation

@emyller

@emyller emyller commented Jun 16, 2026

Copy link
Copy Markdown
Contributor
  • I have read the Contributing Guide.
  • I have added information to docs/ if required so people know about the feature.
  • I have filled in the "Changes" section below.
  • I have filled in the "How did you test this code" section below.

Changes

Closes #7433

  1. Introduces a new endpoint (also to MCP) /api/v1/environments/{environment}/feature-lifecycle-counts/
    {
      "NEW": 475,
      "LIVE": 734,
      "PERMANENT": 190,
      "STALE": 374,
      "NEEDS_MONITORING": 30,
      "TO_REMOVE": 197
    }
  2. Adds new query params to the existing GET /api/v1/projects/{project_pk}/features/ (list):
    • lifecycle_stage: one of stages below; requires environment.
  3. Adds a new attribute lifecycle_stage to the above list endpoint, and also to .../{feature_id} (retrieve), also carrying one of stages below.

Stages logical propositions are as follows:

State Condition
PERMANENT has_permanent_tag
LIVE ~has_permanent_tag AND ~has_stale_tag AND has_code_references
NEW ~has_permanent_tag AND ~has_stale_tag AND ~has_code_references
STALE ~has_permanent_tag AND has_stale_tag AND has_code_references
NEEDS_MONITORING ~has_permanent_tag AND has_stale_tag AND ~has_code_references AND evaluated_recently
TO_REMOVE ~has_permanent_tag AND has_stale_tag AND ~has_code_references AND ~evaluated_recently

How did you test this code?

  • New tests
  • Will gradually roll out in production and collect perf data
  • LLM-assisted benchmarking (does not represent production):
method: synthetic data, InfluxDB analytics backend, local Docker (indicative)
baseline: main's list/detail query path (already annotates code-refs), no lifecycle

small_project:        # 1K flags, 200 in use
  influxdb_query: ~80ms
  feature_list:
    baseline_main: ~2ms
    pr_no_stage_filter: ~40ms
    pr_filtered_by_stage: ~85ms
  feature_detail:
    baseline_main: ~1ms
    pr_with_lifecycle: ~35ms
  stage_counts_endpoint: ~55ms   # new in PR, no baseline

stress_test:          # 30K flags, 600 in use — deliberate worst-case
  influxdb_query: ~120ms
  feature_list:
    baseline_main: ~8ms
    pr_no_stage_filter: ~0.12s
    pr_filtered_by_stage: ~0.45s
  feature_detail:
    baseline_main: ~1ms
    pr_with_lifecycle: ~70ms
  stage_counts_endpoint: ~0.35s

How to review

Reviewing is easier if you split:

  • Part 1: InfluxDB API refactor (to enable tests) — it revealed we need to rewrite it, or maybe invest in something else.
  • Part 2: Feature Lifecycle stage counts API (to feed the count badges in the sidebar.
  • Part 3: Extend the feature list and retrieve endpoints with lifecycle stage information.
  • Part 4: Add filter by lifecycle stage capability to the feature list endpoint.

@emyller emyller self-assigned this Jun 16, 2026
@vercel

vercel Bot commented Jun 16, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

3 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs Ignored Ignored Preview Jun 24, 2026 7:38pm
flagsmith-frontend-preview Ignored Ignored Preview Jun 24, 2026 7:38pm
flagsmith-frontend-staging Ignored Ignored Preview Jun 24, 2026 7:38pm

Request Review

@github-actions github-actions Bot added api Issue related to the REST API docs Documentation updates feature New feature or request and removed docs Documentation updates labels Jun 16, 2026
@kyle-ssg kyle-ssg mentioned this pull request Jun 16, 2026
4 tasks
@emyller emyller force-pushed the feat/feature-lifecycle-api-endpoints branch from 613356f to 69b78cd Compare June 17, 2026 03:34
@github-actions github-actions Bot added docs Documentation updates feature New feature or request and removed feature New feature or request docs Documentation updates labels Jun 17, 2026
@codecov

codecov Bot commented Jun 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.55%. Comparing base (d991940) to head (9a39d26).
⚠️ Report is 12 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7789      +/-   ##
==========================================
- Coverage   98.59%   98.55%   -0.05%     
==========================================
  Files        1472     1482      +10     
  Lines       57370    58045     +675     
==========================================
+ Hits        56564    57204     +640     
- Misses        806      841      +35     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@emyller emyller force-pushed the feat/feature-lifecycle-api-endpoints branch from 3bbd50f to e75211b Compare June 17, 2026 03:49
@github-actions github-actions Bot added the docs Documentation updates label Jun 17, 2026
@github-actions github-actions Bot added feature New feature or request and removed feature New feature or request docs Documentation updates labels Jun 17, 2026
kyle-ssg added a commit that referenced this pull request Jun 24, 2026
Match the feature-lifecycle endpoints introduced in PR #7789:
- lowercase LifecycleStage values + SECTION_TO_STAGE mapping
- env-scoped counts URL (environments/{env}/feature-lifecycle-counts/)
- read lowercase count keys; drop unsupported filter + evaluation_period
  params from the counts query
- remove the orphaned evaluation-period selector (backend derives the
  window from project.stale_flags_limit_days)

Extract prod-environment prediction into predictProdEnvironment().

Add frontend context doc for running an unmerged backend PR's Docker image.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>

@khvn26 khvn26 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code was pretty easy to read through, good job. Just a handful of questions/comments.

Comment thread docs/docs/integrating-with-flagsmith/_mcp-tool-catalogue.md Outdated
Comment thread api/app_analytics/types.py Outdated
Comment thread api/features/feature_lifecycle/views.py
Comment on lines +466 to +470
# NOTE: This field is populated by `features.feature_lifecycle.services.annotate_feature_queryset_with_lifecycle_stage`.
lifecycle_stage = serializers.ChoiceField(
choices=list(LifecycleStage),
read_only=True,
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Do we have an idea of how this will affect influx usage in SaaS prod?
  2. Do we have an idea of the latency hit for the dashboard?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No I don't have numbers for SaaS prod. The plan is to gradually roll this out to a few who're interested in trying it out, and collect real metrics.

On my local benchmarking, added latency is negligible (30K features + simulated usage + code references).

@khvn26 khvn26 Jun 24, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add the results to the PR description? This is a fairly critical path I expect us to include in our SLOs someday.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose it's obvious to expect we'll need to learn from observation and tweak as needed. I deem current numbers are not perfect, but I'd rather not try to optimise early.

Comment thread api/app_analytics/services.py
Comment thread api/features/views.py
Co-authored-by: Kim Gustyr <[email protected]>
@github-actions github-actions Bot added docs Documentation updates feature New feature or request and removed feature New feature or request docs Documentation updates labels Jun 24, 2026
@github-actions github-actions Bot added docs Documentation updates feature New feature or request and removed feature New feature or request docs Documentation updates labels Jun 24, 2026
@github-actions github-actions Bot added docs Documentation updates feature New feature or request and removed feature New feature or request docs Documentation updates labels Jun 24, 2026
@emyller emyller requested a review from khvn26 June 24, 2026 15:16
@github-actions github-actions Bot added the docs Documentation updates label Jun 24, 2026
@github-actions github-actions Bot added feature New feature or request and removed feature New feature or request docs Documentation updates labels Jun 24, 2026
@github-actions github-actions Bot added docs Documentation updates feature New feature or request and removed feature New feature or request docs Documentation updates labels Jun 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api Issue related to the REST API feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve API support for feature lifecycle dashboard

4 participants